#include<stdio.h>
#define yu(a,b) {a=a%b;}
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	yu(n,m);
	printf("%d\n",n);
}
